<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
</body>
<script src="../js/task4.js">
    //请将如下数组使用原型方法排序
    //var arr=[1,5,13,17,22,15,8,6]

    Array.prototype.fall = function () {
        for (let i = 0; i < this.length - 1; i++) {
            for (let j = 0; j < this.length - i - 1; j++) {
                if (this[j] < this[j + 1]) {
                    let t = this[j]
                    this[j] = this[j + 1]
                    this[j + 1] = t
                }
            }
        }
        return this
    }
    Array.prototype.up = function () {
        for (let i = 0; i < this.length - 1; i++) {
            for (let j = 0; j < this.length - i - 1; j++) {
                if (this[j] > this[j + 1]) {
                    let t = this[j]
                    this[j] = this[j + 1]
                    this[j + 1] = t
                }
            }
        }
        return this
    }

    let s = [1, 5, 13, 17, 22, 15, 8, 6]
    console.log(s.fall());
    console.log(s.up());
</script>

</html>